<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<script src="../js/vue.min.js" type="text/javascript" charset="utf-8"></script>
		<style type="text/css">
			li{
				list-style: none;
				border: 1px dashed #999;
				margin: 5px;
				line-height: 35px;
				padding-left: 5px;
				font-size: 12px;
				cursor: pointer;
				width: 100%;
				float: left;
			}
			li:hover{
				background-color: hotpink;
				transition: all 0.8s ease;
			}
			.v-enter,.v-leave-to{
				opacity: 0;
				transform: translateY(80px);
			}

			.v-enter-active,.v-leave-to-active{
				transition: all 0.6s ease;
			}
			/*v-move  v-leave-active 配合使用，实现列表后续元素，渐渐飘上来*/
			.v-move{
				transition: all 0.6s ease;
			}
			.v-leave-active{
				position: absolute;
			}
		</style>
	</head>
	<body>
		<div id="app">
			<input type="text" id="" value=""  v-model="id"/>
			<input type="text" id="" value="" v-model="name"/>
			<input type="button" id="" value="Add" @click="add"/>
			<!--
				使用v-for循环渲染出来的，不能使用transition包裹，需要使用transition-group
				如果要为v-for循环创建元素设置动画，必须为每一个元素设置：key属性
				给 transition-group添加appear属性，实现页面刚展示的入场动画效果
				通过为 transition-group 元素设置，tag属性，指定transition-group 渲染为指定的元素，如果不指定tag属性，默认渲染为 span 标签
			-->
				<transition-group appear tag="ul">
					<li v-for="(item,index) in list" :key="item.id" @click="del(index)">{{item.id}}------------{{item.name}}</li>
				</transition-group>
		</div>
		<script type="text/javascript">
			new Vue({
				el:"#app",
				data:{
					id:"",
					name:"",
					list:[
						{id:1,name:"仲达"},
						{id:2,name:"仲达"},
						{id:3,name:"仲达"},
						{id:4,name:"仲达"},
						{id:5,name:"仲达"},
						{id:6,name:"仲达"},
						{id:7,name:"萌德"}
					]
				},
				methods:{
					add(){
						this.list.push({id:this.id,name:this.name})
						this.id=this.name=""
					},
					del(index){
						this.list.splice(index,1) 
					}
				}
			});
		</script>
	</body>
</html>
